import time

from selenium.webdriver.common.by import By

from common.base import Base
from common.functions import open_browser


class GeOrder(Base):
    def order_operation(self):
        self.click((By.LINK_TEXT,'服装'))

    def buy_bnt(self):
        self.click((By.XPATH,'//a[@class="price-btn"and @href="goods.php?id=48"]'))

    def  buy_bnt_now(self):
        self.click((By.XPATH,"//td[@class='td1']//img"))

    def go_pay(self):
        self.click((By.XPATH,'//img[@alt="checkout"]'))

    def select_bank(self):
        self.click((By.XPATH,"//input[@type='radio'and@name='payment'and@value='2']"))

    def submitorder(self):
        time.sleep(2)
        self.click((By.XPATH,'//div[@align="center"]//input[1]'))


if __name__ == '__main__':
    drver=open_browser()
    go = GeOrder(drver)
    go.input_url('http://139.129.26.163/index.php')
    go.order_operation()
    go.buy_bnt()
    go.buy_bnt_now()
    go.go_pay()
    go.select_bank()
    go.submitorder()
    go.quit()




